package br.eng.megaprojetos.control;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import br.com.vexillum.util.Return;
import br.eng.megaprojetos.model.interfaces.IPerson;

@Service
@Scope("prototype")
public abstract class PersonController<P extends IPerson> extends BasicMegaController<P> {
	
	public PersonController() {
		super(null);
	}
	
	public PersonController(Class<P> classEntity) {
		super(classEntity);
	}
	
	public Return getPersonByCGC() {
		Return retPerson = new Return(true);
		String cgc = (String) data.get("cgc");
		String sql = "FROM Person where cgc = '" + cgc + "'";
		data.put("sql", sql);
		retPerson.concat(searchByHQL());
		return retPerson;
	}
	
	public Return getPersonExtensionByCGC() {
		Return retPerson = new Return(true);
		String cgc = (String) data.get("cgc");
		String sql = "FROM" + classEntity + "where cgc = '" + cgc + "'";
		data.put("sql", sql);
		retPerson.concat(searchByHQL());
		return retPerson;
	}
	
	@Override
	public Return searchByCriteria() {
		return super.searchByHQL();
	}
	
}
